package gui.popupmenu;

import gui.image.ImagePanel;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import javax.swing.JPanel;

/**
 *
 * @author Quân
 */
public class DeleteMouseAdaptor extends MouseAdapter {

    private ImagePanel imagePanel;

    public DeleteMouseAdaptor(ImagePanel imagePanel) {
        this.imagePanel = imagePanel;
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        JPanel jPanel = (JPanel) imagePanel.getParent();
        jPanel.remove(imagePanel);
        jPanel.updateUI();

        File file = imagePanel.getFile();
        file.delete();
    }
}
